import java.io.Serializable;
import java.text.NumberFormat;
import java.util.Date;


public class LogLine implements Serializable{
	private Rekening from;
	private Rekening to;
	private String description;
	private Date timestamp;
	private double amount;
	
	public LogLine(Rekening from, Rekening to, double amount){
		this(from, to, amount, "");
	}
	
	public LogLine(Rekening from, Rekening to, double amount, String description){
		this.from = from;
		this.to = to;
		this.amount = amount;
		this.description = description;
		this.timestamp = new Date();
		
	}
	
	@SuppressWarnings("deprecation")
	public String toString(){
		if(this.to == null){
			return "["+this.timestamp.toLocaleString()+"] Opname:      "+NumberFormat.getCurrencyInstance().format(this.amount)+((this.description.length()>0)?" ("+this.description+")":"");
		}else if(this.from == null){
			return "["+this.timestamp.toLocaleString()+"] Storting:    "+NumberFormat.getCurrencyInstance().format(this.amount)+" "+((this.description.length()>0)?" ("+this.description+")":"");
		}else{
			return "["+this.timestamp.toLocaleString()+"] Overboeking: "+NumberFormat.getCurrencyInstance().format(this.amount)+" werd van "+from.getRekNr()+" naar "+to.getRekNr()+" overgeboekt. "+((this.description.length()>0)?" ("+this.description+")":"");
		}
	}
}
